#ifndef _TORSION_SPRING_H
#define _TORSION_SPRING_H

#include "Constraint.h"
#include "Particle.h"

/*
 * TorsionSpring is a angle preserving constraint.
 * Torsion springs obey an angular form of Hooke's law:
 * 	T = -k*theta
 * t -- torque (N*m)
 * k -- constant (N*m/rad)
 * theta -- angular deviation wrt the resting angle (rad)
 *
 * Here the resting/current angles are specified by 4 points (2 triangles):
 * 	1   2
 *        \
 * 	3   4
 */
class TorsionSpring: public Constraint {
public:
	Particle* p1;
	Particle* p2;
	Particle* p3;
	Particle* p4;
	double restAngle;
	double stiffness;
public:
	TorsionSpring(Particle* p1, Particle* p2, Particle* p3, Particle* p4, double _stiffness);
	void satisfyConstraint();
private:
	double computeAngle();
};

#endif /* _TORSION_SPRING_H */
